﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace FileManager
{
    public class RegexProcess
    {
        public static bool IsIP(string Ip)
        {
            //判断是否为IP
            string pattrn = @"(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])";
            return Regex.IsMatch(Ip, pattrn);
        }

        public static string RepalceSpace(string Str)
        {
            Regex regex = new Regex("\\s+");
            return regex.Replace(Str, "");
        }
        public static bool IsPath(string Path)
        {
            string pattrn = @"[a-zA-Z]\:[\\a-zA-Z0-9_\\]+[\.]?[a-zA-Z0-9_]+";
            return Regex.IsMatch(Path, pattrn);
        }
    }
}
